/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package epaper;

import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 *
 * @author Puneet
 */
public class HT extends CommonClient {

    public HT(String lang, int city, String fileName, Date date) {
        super(lang,city,fileName,date);
    }


    

    public void buildURL(String lang, int city, Date date) {

        Format format = new SimpleDateFormat("yyyy/MM/dd");
        String dateStr = format.format(date);
        String pageStr = new SimpleDateFormat("dd_MM_yyyy_").format(date);
        if (Language.ENGLISH.name().toUpperCase().startsWith(lang.toUpperCase())) {
            urlStr = new StringBuilder("http://epaper.hindustantimes.com/PUBLICATIONS//HT/");
            mergePaper = new StringBuilder(basefile + "Hindustan_Times");
            if(city == Cities.getInstance().DELHI){
                urlStr.append("HD/");
            } else if(city == Cities.getInstance().MUMBAI){
                urlStr.append("HM/");
            } else if(city == Cities.getInstance().KOLKATA){
                urlStr.append("HKL/");
            } else if(city == Cities.getInstance().CHANDIGARH){
                urlStr.append("HC/");
            } else {
                System.out.println("INVALID CITY");
                System.exit(0);
            }
            mergePaper.append("_").append(Cities.getInstance().getCity(city));


        } else if (Language.HINDI.name().toUpperCase().startsWith(lang.toUpperCase())) {
            urlStr = new StringBuilder("http://epaper.hindustandainik.com/PUBLICATIONS//HT/");
            mergePaper = new StringBuilder(basefile + "Hindustan_Dainik");
            if(city == Cities.getInstance().DELHI){
                urlStr.append("HT/");
            } else if(city == Cities.getInstance().RANCHI){
                urlStr.append("HR/");
            } else if(city == Cities.getInstance().PATNA){
                urlStr.append("HP/");
            } else if(city == Cities.getInstance().LUCKNOW){
                urlStr.append("HL/");
            } else {
                System.out.println("INVALID CITY");
                System.exit(0);
            }
            mergePaper.append("_").append(Cities.getInstance().getCity(city));
        } else {
            System.out.println("INVALID LANGUAGE");
            System.exit(0);
        }

        mergePaper.append("_").append(pageStr).append(".pdf");

        urlStr.append(dateStr);
        urlStr.append("/PagePrint/");
        urlStr.append(pageStr);
    }

    public String buildPageUrl(int pagenumber){
        return urlStr.toString() + getThreeDigitString(pagenumber) + ".pdf";
    }

    


    
}

